new Vue({
    el: '#app',
    data: {
        title: [
            '商品序号',
            '商品名称',
            '商品价格',
            '编辑商品'
        ],
        goods: [{
                name: '苹果',
                price: 5.2
            },
            {
                name: '香蕉',
                price: 3.5
            }
        ],
        name: '',
        price: ''
    },
    methods: {
        add: function () {
            var str = {
                name: this.name,
                price: this.price
            };
            // 将数据添加到数组末尾，添加到起始用unshift()
            this.goods.push(str);
        },
        del: function (i) {
            // 删除数组元素，splce(1,1,"x")表示添加元素
            this.goods.splice(i, 1);
        }
    },
    filters: {
        currency: function (value) {
            return '￥' + value.toFixed(2);
        }
    }
});